package abstractFactory;

import abstractFactory.colorFactory.interAndImpl.Color;
import abstractFactory.shapeFactory.interAndImpl.Shape;

public class AbstractFactoryPatternDemo {
    public static void main(String[] args) {
        //获取形状工厂
        AbstractFactory shapeFactory=FactoryProducer.getFactory("SHAPE");
        //获取形状为Circle的对象。调取Circle的draw方法
        Shape shape1=shapeFactory.getShape("CIRCLE");
        shape1.draw();

        Shape shape2=shapeFactory.getShape("SQUARE");
        shape2.draw();

        Shape shape3=shapeFactory.getShape("RECTANGLE");
        shape3.draw();
        //获取颜色工厂
        AbstractFactory colorFactory=FactoryProducer.getFactory("COLOR");
        //获取颜色为Red的对象，调用Red的fill方法
        Color color1=colorFactory.getColor("RED");
        color1.fill();

        Color color2=colorFactory.getColor("GREEN");
        color2.fill();

        Color color3=colorFactory.getColor("BULE");
        color3.fill();
    }
}
